package com.yowasa.xiuxian.engine.battle.strategy.drop.all;

import com.google.common.collect.Lists;
import com.yowasa.xiuxian.annoations.BS;
import com.yowasa.xiuxian.engine.battle.strategy.CalAbility;
import com.yowasa.xiuxian.engine.battle.strategy.InherentStrategy;
import com.yowasa.xiuxian.entity.bo.battle.BattleContent;
import com.yowasa.xiuxian.entity.bo.battle.UserBattleContent;
import com.yowasa.xiuxian.entity.bo.user.UserBO;
import com.yowasa.xiuxian.entity.enums.ElementEnum;
import com.yowasa.xiuxian.entity.enums.InherentTiming;
import com.yowasa.xiuxian.exception.HandlerException;
import com.yowasa.xiuxian.service.helper.BattleHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.util.List;

@BS(name="俱收并蓄")
@Order(1000)
@Component
public class JuShouBingXu extends CalAbility implements InherentStrategy {
    @Autowired
    private BattleHelper battleHelper;

    @Override
    public ElementEnum getElement() {
        return null;
    }
    @Override
    public void action(UserBattleContent first, UserBattleContent second, BattleContent content) {
        first.getBattleInfo().setDef((int) (first.getBattleInfo().getDef() + first.getUserBO().getUserBattle().getDef() * 0.2));
        first.getBattleInfo().setRes((int) (first.getBattleInfo().getRes() + first.getUserBO().getUserBattle().getRes() * 0.2));

        int atk = (int)( (first.getBattleInfo().getRes()+first.getBattleInfo().getDef()) * 0.5);
        int def = second.getBattleInfo().getDef() ;
        int dmg = battleHelper.calAtk(atk, def);
        second.getBattleInfo().setChp(second.getBattleInfo().getChp() - dmg);

        content.getMsgLog().add("你的双抗提升了，岩脊造成了"+dmg+"点伤害");
    }

    @Override
    public void limit(UserBO user) {
        throw new HandlerException("该战技无法直接学习，需要拥有 装备-[千岩同心] ，装备在身上时自动学会");

    }

    @Override
    public String limitDesc() {
        return "学习/使用俱收并蓄需要拥有 装备-[千岩同心] ";
    }

    @Override
    public boolean check(UserBattleContent user, BattleContent content) {
        return true;
    }

    @Override
    public String desc() {
        return "俱收并蓄，天理常驱。召唤岩脊立在场上，敌方回合行动开始时会为你增加20%的双抗，\n对面还会受到你双抗总和*0.5的物理伤害。\n天动万象，拒收病婿！";
    }

    @Override
    public List<InherentTiming> getTiming() {
        return Lists.newArrayList(InherentTiming.OPPONENT_END);
    }
}
